from langchain.tools import Tool

import json

from .body_move_prompt import tool_prompt_rob_walk


def rob_walk(move_info) -> bool:
    try:
        # print(direction, speed, distance)
        print(move_info)
        move_info = json.loads(move_info)
        direction = move_info['direction']
        speed = float(move_info['speed'])
        distance = float(move_info['distance'])
        print(f"机器人向{direction}以{speed} km/h的速度行进了{distance}米。")
        return True
    except:
        print("机器人分析指令失败，请重新输入")
        return False


robot_walk_tool = Tool(
        name="rob_walk",
        func=rob_walk,
        description=tool_prompt_rob_walk,
        )